System and method for on-the-fly, post-processing document object model manipulation

ABSTRACT

A method and system for on-the-fly post-processing of a Document Object Model of a Web-page server-side is disclosed herein. The present invention analyzes the Web-page and builds a Document Object Model of the Web-page on the server-side. The present invention then identifies a plurality of elements of the Document Object Model of the Web-page for manipulation, manipulates the plurality of elements of the Document Object Model of the web-page to create a Web-page with a manipulated Document Object Model, and transmits the Web-page with the manipulated Document Object Model to the client-side.

CROSS REFERENCE TO RELATED APPLICATION

This Application claims priority to U.S. Provisional Patent ApplicationNo. 60/989,909, filed on Nov. 23, 2007, which is hereby incorporated byreference in its entirety.

STATEMENT REGARDING FEDERALLY SPONSORED RESEARCH OR DEVELOPMENT

Not Applicable

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention is related to development of Web-sites andWeb-applications. More specifically, the present invention relates todocument object model manipulation.

2. Description of the Related Art

Prior to Rich Internet Applications, traditional Web applicationsinvolved a client-server architecture with all of the processing on theserver side and the client-side used to display the HTML web-pagesserved by the server. Each time a user desired to view a new Web-page, aHTTP request was sent to the server and the requested Web-page wasserved to the Web browser on the client-side. Such a traditional systemis shown in FIG. 1 with a Web-server 1000 on a server side receivingrequests over the Internet 1005 from a Web-browser 1003 on aclient-side.

Rich Internet Applications, such as Ajax, greatly improved on thetraditional client-server architecture by allowing the client machine todynamically render and partially refresh web pages based on an initialset of instructions from the server, user input, and small amounts ofsubsequent data dynamically requested from the server. As shown in FIG.2, the client machine processes Ajax instructions to render a Web pagefor the user.

Early Web applications allowed a user's browser to send a request to aserver. The server processed the request and responded to the browserwith a Web page. When the user wanted to view a new page, anotherrequest was sent to the server and the server responded to the browserwith a new Web page. Such a process resulted in a waste of bandwidthsince much of the Web contents in the first Web page were also containedin the second web page. The need to resend the same information led to amuch slower user interface of a Web application than that of a nativeapplication.

An emerging technology, called Ajax (Asynchronous and JavaScript XML),was developed for refreshing part of a page instead of refreshing thewhole page on every interaction between the user and application. In anAjax application, when a user submits a form in a page, a scriptprogram, usually a JavaScript program, resident on the Web browserreceives the user's request and sends a XML (Extended Markup Language)HTTP (Hyper Text Transfer Protocol) request to the Web server inbackground so as to retrieve only the needed Web contents instead of thewhole page and perform corresponding processing to partly refresh thepage when receiving a response from the Web server. In this way, theapplication response time is shortened, because the amount of dataexchanged between the Web browser and the Web server is greatly reduced.And the processing time of the Web server is saved because much of theprocessing is performed at the client side.

General definitions for terms utilized in the pertinent art are setforth below.

Ajax is the use of dynamic HTML, JavaScript and CSS to create dynamicand usually interactive Web sites and applications. A more detailedexplanation of Ajax is set forth in Edmond Woychowsky, AJAX, CreatingWeb Pages with Asynchronous JavaScript and XML, Prentice Hall, 2007,which is hereby incorporated by reference in its entirety.

Applets or Java Applets are mini-executable programs named with the.class suffix and are placed on a Web page and provide interactive andmultimedia uses.

Application Programming Interface (API) is a collection of computersoftware code, usually a set of class definitions, that can perform aset of related complex tasks, but has a limited set of controls that maybe manipulated by other software-code entities. The set of controls isdeliberately limited for the sake of clarity and ease of use, so thatprogrammers do not have to work with the detail contained within thegiven API itself.

An Attribute provides additional information about an element, object orfile. In a Document Object Model, an attribute, or attribute node, iscontained within an element node.

Behavioral layer is the top layer and is the scripting and programmingthat adds interactivity and dynamic effects to a site.

Binding in a general sense is the linking of a library to an applicationprogram usually to prevent repetition of frequently utilized code.

Cascading Style Sheets (CSS) is a W3C standard for defining thepresentation of Web documents.

Compiler is a computer program that translates a series of instructionswritten in one computer language into a resulting output in a differentcomputer language.

Document Object Model (DOM) Element is an object contained in a DocumentObject Model (DOM). The term DOM is generally used to refer to theparticular DOM held in the memory region being used by the Web browser.Such a DOM controls the Graphical Respondent Interface (GRI) orGraphical User Interface (GUI). The DOM is generated according to theinformation that the Web browser reads from the HTML file, and/or fromdirect JavaScript software instructions. Generally, there exists aunique DOM element for every unique HTML element. DOM elements aresometimes referred to as HTML/DOM elements, because the DOM elementexists only because HTML code that was read by the Web browser listedsome HTML element that had not previously existed, and thereby causedthe Web browser to create that DOM element. Often specific elements ofthe greater set of HTML/DOM elements are identified by specifying anHTML/DOM checkbox element, or an HTML/DOM text input element. A moredetailed explanation of the document object model is set forth in JeremyKeith, DOM Scripting, Web Design with JavaScript and the Document ObjectModel, friends of, 2005, which is hereby incorporated by reference inits entirety.

HyperText Markup Language (HTML) is a method of mixing text and othercontent with layout and appearance commands in a text file, so that abrowser can generate a displayed image from the file.

Hypertext Transfer Protocol (HTTP) is a set of conventions forcontrolling the transfer of information via the Internet from a Webserver computer to a client computer, and also from a client computer toa Web server.

Internet is the worldwide, decentralized totality of server computersand data-transmission paths which can supply information to a connectedand browser-equipped client computer, and can receive and forwardinformation entered from the client computer.

JavaScript is an object-based programming language. JavaScript is aninterpreted language, not a compiled language. JavaScript is generallydesigned for writing software routines that operate within a clientcomputer on the Internet. Generally, the software routines aredownloaded to the client computer at the beginning of the interactivesession, if they are not already cached on the client computer.JavaScript is discussed in greater detail below.

JSON is JavaScript Object Notation format, which is a way of taking dataand turning it into valid JavaScript syntax for reconstituting an objectat the other end of the transmission protocol.

MySQL is a relational database management system which relies on SQL forprocessing data in a database.

Parser is a component of a compiler that analyzes a sequence of tokensto determine its grammatical structure with respect to a given formalgrammer. Parsing transforms input text into a data structure, usually atree, which is suitable for later processing and which captures theimplied hierarchy of the input. XML Parsers ensure that an XML documentfollows the rules of XML markup syntax correctly.

PHP is a scripting language that allows developers create dynamicallygenerated Web pages, and is used for server-side programming.

Platform is the combination of a computer's architecture, operatingsystem, programming language (PHP, JAVA, RUBY ON RAILS), runtimelibraries and GUIs.

Presentation layer follows the structural layer, and providesinstructions on how the document should look on the screen, sound whenread aloud or be formatted when it is printed.

Rendering engine is software used with a Web browser that takes Webcontent (HTML, XML, image files) and formatting information (CSS, XSL)and displays the formatted content on a screen.

Serialization places an object in a binary form for transmission acrossa network such as the Internet and deserialization involves extracting adata structure from a series of bytes.

SQL (Structured Query Language) is a computer language designed for dataretrieval and data management in a database.

Structural layer of a Web page is the marked up document and foundationon which other layers may be applied.

User is a client computer, generally operated by a human being, but insome system contexts running an automated process not under full-timehuman control.

Web-Browser is a complex software program, resident in a clientcomputer, that is capable of loading and displaying text and images andexhibiting behaviors as encoded in HTML (HyperText Markup Language) fromthe Internet, and also from the client computer's memory. Major browsersinclude MICROSOFT INTERNET EXPLORER, NETSCAPE, APPLE SAFARI, MOZILLAFIREFOX, and OPERA.

Web-Server is a computer able to simultaneously manage many Internetinformation-exchange processes at the same time. Normally, servercomputers are more powerful than client computers, and areadministratively and/or geographically centralized. An interactive-forminformation-collection process generally is controlled from a servercomputer, to which the sponsor of the process has access.

World Wide Web Consortium (W3C) is an unofficial standards body whichcreates and oversees the development of web technologies and theapplication of those technologies.

XHTML (Extensible Hypertext Markup Language) is a language fordescribing the content of hypertext documents intended to be viewed orread in a browser.

XML (Extensible Markup Language) is a W3C standard for text documentmarkup, and it is not a language but a set of rules for creating othermarkup languages.

There are three types of JavaScript: 1) Client-side JavaScript; 2)Server-side JavaScript; and 3) Core JavaScript. Client-side JavaScriptis generally an extended version of JavaScript that enables theenhancement and manipulation of web pages and client browsers.Server-side JavaScript is an extended version of JavaScript that enablesback-end access to databases, file systems, and servers. Core JavaScriptis the base JavaScript.

Core JavaScript includes the following objects: array, date, math,number and string. Client-side JavaScript and Server-side JavaScripthave additional objects and functions that are specific to client-sideor server-side functionality. Generally, any JavaScript libraries (.jsfiles) created in core JavaScript can be used on both the client and theserver without changes. Client-side JavaScript is composed of a CoreJavaScript and additional objects such as: document, form, frame andwindow. The objects in Client-side JavaScript enable manipulation ofHTML documents (checking form fields, submitting forms, creating dynamicpages) and the browser (directing the browser to load other HTML pages,display messages). Server-side JavaScript is composed of Core JavaScriptand additional objects and functions for accessing databases and filesystems, and sending email. Server-side JavaScript enables Webdevelopers to efficiently create database-driven web applications.Server-side JavaScript is generally used to create and customizeserver-based applications by scripting the interaction between objects.Client-side JavaScript may be served by any server but only displayed byJavaScript-enabled browsers. Server-side JavaScript must be served by aJavaScript-enabled server but can be displayed by any browser.

Mocket et al., United States Patent Publication Number 20010037359 for aSystem And Method For A Server-side Browser Including Markup LanguageGraphical User Interface, Dynamic Markup Language Rewriter Engine AndProfile Engine describes a system and method for a server-side browserincluding markup language graphical user interface, dynamic markuplanguage rewriter engine and profile engine. The system includes a usercomputer and a destination server computer separated by a servercomputer hosting a server-side browser (SSB). The SSB includes a markuplanguage graphical user interface (MLGUI), a dynamic markup languagerewriter engine (DMLRE) and a profiling engine (PE). The SSB may beconfigured as an intermediary infrastructure residing on the Internetproviding customized information gathering for a user. The components ofthe SSB allow for controlling, brokering and distributing informationmore perfectly by controlling both browser functionality (on theclient-side) and server functionality (on the destination site side)within a single point and without the necessity of incremental consentsor integration of either side.

Irassar et al., United States Patent Publication Number 20040250262, forBusiness To Business Event Communications discloses an event handlingmechanism that allows communication of event information among providersand subscribers across a network using an event handling server.

Jennings et al., United States Patent Publication Number 20070073739 fora Data-Driven And Plug-In Defined Event Engine, discloses an eventengine that enables application developers to define finite statemachines for implementation via a data-driven approach using executableplug-ins.

Lindhorst et al., U.S. Pat. No. 6,981,215 for a System For ConvertingEvent-Driven Code Into Serially Executed Code, discloses an event-drivenserver model that uses active server pages that appear to other files asobjects with associated method and properties for developing Web pages.

However, current technologies that operate Server-side JavaScript failto offer complete interactions which are the hallmark of rich web sitesand applications. For example, the on-the-fly manipulation of thedocument object model is desired.

BRIEF SUMMARY OF THE INVENTION

The Present Invention overcomes the obstacles of the prior art. Thepresent invention allows for post-processing DOM. Elements of theWeb-page or Web-application are replaced by newer versions, removed ifinappropriate, repositioned or repurposed elsewhere on the Web-page orWeb-application. Also, elements of the Web-page or Web-application arere-branded, adjusted to improve accessibility for the disabled,compressed, cached, or manipulated in other ways.

The Present Invention overcomes the obstacles of the prior art. Becausethe present invention (usually acting as an on-the-fly post-processor)natively understands the Web content being served, it can be used tooptimize that content, or to offer visibility on where the load may bereduced and the performance, both real and perceived, may be improved.

The present invention parses and executes the Web-page as a browserwould parse the web-page. The present invention is configured to executeall or part of the code on that page, load external resources or not,and call various external systems in the course of processing theWeb-page. As a result, the present invention can faithfully analyze theload-producing traffic in real time, e.g. monitoring how many links tocertain resources are really being sent, whether they are clustered incertain ways (e.g. per page, per application or site, per user, persession), how much overlap they contain, and where do they appear andhow their content is being used. In addition to reporting all this dataand presenting the data in various ways to the system operators, thepresent invention effects certain optimizations. For example, thepresent invention aggregates multiple JavaScript and CSS files intosingle files, caches them, and replaces the multiple links to theoriginal files into single links to the new files, thus reducing thenumber of network trips needed to complete the Web-page. The presentinvention delivers only the pieces of code that are used often, andproxies the rest of the code to deliver them on demand. The presentinvention reassembles JavaScript files for more optimal caching on theclient and fewer network trips, and present invention can do so forimages too using a technique known as image sprites. Further the presentinvention does all of this without changing the original code and filesused to generate the web-pages. The on-the-fly (runtime) information andoptimizations are then used as actionable feedback to change theoriginal code and files or for building new code and files better.

One aspect of the present invention is a method for on-the-flypost-processing of a Document Object Model of a web-page server-side.The method includes transmitting a request for a web-page from aclient-side, with the web-page comprising a Document Object Model. Themethod includes retrieving the web-page at a server side. The methodalso includes analyzing the Document Object Model of the web-page at theserver-side. The method also includes identifying a plurality ofelements of the Document Object Model of the web-page for manipulation.The method also includes manipulating the plurality of elements of theDocument Object Model of the web-page to create a web-page with amanipulated Document Object Model. The method also includes transmittingthe web-page with the manipulated Document Object Model to theclient-side.

The manipulating the plurality of elements of the Document Object Modelof the Web-page step preferably is replacing the plurality of elementswith a newer version of the element.

The manipulating the plurality of elements of the Document Object Modelof the Web-page step alternatively includes removing at least one of theplurality of elements of the Document Object Model of the Web page.

The manipulating the plurality of elements of the Document Object Modelof the web-page step alternatively includes repositioning at least oneof the plurality of elements of the Document Object Model of the Webpage.

The manipulating the plurality of elements of the Document Object Modelof the Web-page step alternatively includes repurposing at least one ofthe plurality of elements of the Document Object Model of the Web page.

The manipulating the plurality of elements of the Document Object Modelof the Web-page step alternatively includes rebranding at least one ofthe plurality of elements of the Document Object Model of the Web page.

The manipulating the plurality of elements of the Document Object Modelof the Web-page step alternatively includes adjusting for improvedaccessibility at least one of the plurality of elements of the DocumentObject Model of the Web page.

The manipulating the plurality of elements of the Document Object Modelof the Web-page step alternatively includes compressing at least one ofthe plurality of elements of the Document Object Model of the Web page.

The manipulating the plurality of elements of the Document Object Modelof the Web-page step alternatively includes caching at least one of theplurality of elements of the Document Object Model of the Web page.

Another aspect of the present invention is a system for on-the-flypost-processing of a Document Object Model of a Web-page on aserver-side. The system includes a Web-page, a network, a Web-browserand a Web-server. The Web-page includes a Document Object Model. Theweb-browser having means for transmitting a request for the Web-pageover the network. The Web-server includes a means for retrieving theWeb-page, a JavaScript parser and engine for analyzing the DocumentObject Model of the Web-page, means for identifying a plurality ofelements of the Document Object Model of the web-page for manipulation,means for manipulating the plurality of elements of the Document ObjectModel of the Web-page to create a Web-page with a manipulated DocumentObject Model, and means for transmitting the Web-page with themanipulated Document Object Model to the client-side over the network.

To understand the differences between the server and browser sides, it'simportant to keep in mind the page lifecycle. The page request from thebrowser is received by the Web server, which fetches the appropriateHTML document (either from the file system or perhaps from another“handler” such as PHP or Ruby or Java). The Web server (Apache server)then feeds the document to the script server of the present invention,which begins to parse the HTML document and builds up the DOM tree. Whenthe script server encounters <script> tags the script server not onlyadds them to the DOM but may also execute them if they have a runatattribute that indicates they should run on the server. During theparsing and execution, external content may also be fetched and loadedinto the document, via <script src=“ . . . ”></script> elements andJaxer.load( . . . ) for JavaScript code, or via <jaxer:include src=“ . .. ”></jaxer:include> (or <jaxer:include path=“ . . . ”></jaxer:include>)for HTML content, or via XMLHttpRequests for any content. After the DOMis fully loaded, the onserverload event is fired. This is theserver-side equivalent of the onload event on the browser. Theonserverload event is named differently so that a developer's code canreact separately to onserverload and onload events. The script serverpost-processes the DOM to carry out its built-in logic and prepare theDOM for sending to the browser: removing <script> blocks meant only forthe server, replacing functions to be proxied with proxies, saving (asneeded) functions that should be available on callbacks, . . . etc.Finally, the DOM is serialized back to HTML, and that HTML is streamedback via the Web server to the browser.

The resulting HTML page is sent back to the browser as the response tothe browser's request. The browser begins to parse the HTML, building upthe DOM. When the browser encounters <script> tags the browser not onlyadds them to the DOM but also executes them. External JavaScript code orany other content may also be loaded. The onload event fires. Of coursethe page is progressively rendered throughout much of this flow, andalso the user can interact with it.

Callbacks from the browser to server-side functions are handled viaXMLHttpRequests. When the script server receives such a request, itcreates a new, empty document (unless configured to use a differentstatic document). The script server retrieves the saved functions thatare needed to be made available during callbacks to this page. If afunction called oncallback is found, it is executed. This is usuallyused to create the environment needed during a callback, if the savedfunctions are not enough. The callback function itself is executed.Finally, the result of that execution is packaged and returned as theresponse to the XMLHttpRequest.

While a DOM is available during callback processing, it is notserialized as HTML and returned as the response, as it was during the“regular” (non-callback) page processing flow. The DOM on script serverand the DOM on the browser typically are not synchronized. Both arecreated from the same HTML source, but they are often subject toprocessing by different JavaScript code, and both come to life atdifferent points in the page lifecycle: the DOM on the script serverexists temporarily when the page is processed by the script server, andis eliminated after it's been serialized into the HTML sent to thebrowser; the DOM in the browser is built, on the browser, from thatHTML, and is the DOM that's rendered to the user and with which theend-user interacts.

While script server and the browser may well share some code (e.g. whenusing runat=“both”), usually the JavaScript code designated to run onscript server and interacting with the script server DOM is differentthan the code designated to run on the client. The latter exists e.g. asa <script> tag in the script server DOM but is not executed in scriptserver.

Remember that the only things sent to the browser at the end of pageprocessing is what's actually in the DOM, and what the script server ofthe present invention has added such as proxies, clientData, andinjected scripts. For example, if a developer added an expando property,which is an in-memory change to the DOM that will not get serialized, itwill not appear on the client side.

var div=document.createElement (“div”);

div.id=“myDiv”;

document.body.appendChild(div);

document.getElementById(“myDiv”).userId=123;

On the browser the div is present, with an id of “myDiv”, but without a“userId” property. For this same reason, setting event handlersprogrammatically rather than in the DOM will not translate to DOMchanges and hence will not propagate to the browser. For example with abutton: <input type=“button” id=“myButton” value=“Click me”>

A developer could add an onclick=“ . . . ” attribute to the tag, butthis does not assist with adding the event handler programmatically. Thescript server of the present invention provides Jaxer.setEvent(domElement, eventName, handler) function that “does the right thing” inthe script server as well as on the browser. varbtn=document.getElementById(“myButton”); function sayHi( ) {alert(“hi”)} sayHi.runat=“client”; Jaxer.setEvent(btn, “onclick”, sayHi);

The function used as the event handler should be made available to thebrowser. When setEvent is executed on the server, as above, it resultsin the following change to the myButton element: <input type=“button”id=“myButton” value=“Click me” onclick=“sayHi( )”> This is sent to thebrowser since it is a DOM change. If the function passed into setEventhas no name, its body (source) is used as the value of the attribute:var btn=document.getEleemntById(“myButton”); Jaxer.setEvent(btn,“onclick”, function( ) {alert(“hi”);});

This results in the following: <input type=“button” id=“myButton”value=“Click me” onclick=“(function( ) {alert(\“hi\);})( )”>

Which is useful for short functions but is easier to pass in the code toexecute as a string: varbtn=document.getEleemntById(“myButton”);Jaxer.setEvent(btn, “onclick”,“alert(‘hi’)”);

Which results in:<input type=“button” id=“myButton” value=“Click me”onclick=“alert(‘hi’)”>

The environment of the present invention is preferably based upon thevery same Mozilla engine which powers Firefox 3. This means that, forthe most part, DOM interaction in the server using the present inventionis the same as interacting with the DOM in a Web browser. It parses andexecutes pages progressively, building up the DOM as it goes along, andallowing JavaScript to interact with whatever DOM has already been builtup at the time the JavaScript executes. Any document.write( ) calls willwrite to the DOM immediately following the current location on the page.The JavaScript that is part of a page, and loaded into the page,executes within the context of the global window object. For eachrequest at the server, the present invention preferably provides adocument object model. This DOM (which we'll refer to as DOM1) can beused to insert data and otherwise transform the page before it is firstreturned to the browser. You interact with and manipulate the DOM muchthe same as you would in the browser. Some third party Javascripttoolkits, such as jQuery, can also be used to modify this DOM. Thedocument is accessible through the document object, and the root elementof the DOM is accessible through the document.documentElement object. Toensure that element properties are serialized properly when the DOM isreturned to the browser, use element.setAttribute(“attr”, “value”)rather than element.foo=“value”. Form element values set withformElement.value [code font] are an exception; they'll still beserialized as expected. To attach an event handler to an element,preferably use the special Jaxer method Jaxer.setEvent( ). Example:Transforming the DOM.

<script type=“text/javascript” runat=“server”>

window.onserverload=function( ) {

-   -   var textNode=document.createTextNode(“wocka wocka wocka”);    -   var element=document.getElementById(“container”);    -   element.appendChild(textNode);

};

</script>

A developer can manipulate the DOM in the API's, for example by usingthe following:

<script runat=“server”>

-   -   Document.getElementById(‘useBillingAddrChkbox’).checked=Jaxer.session.get(‘userSessionBillingAddrValue’);        </script>

Having briefly described the present invention, the above and furtherobjects, features and advantages thereof will be recognized by thoseskilled in the pertinent art from the following detailed description ofthe invention when taken in conjunction with the accompanying drawings.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

FIG. 1 is a block diagram of a web system of the prior art.

FIG. 2 is a block diagram of a web system of the prior art.

FIG. 3 is a block diagram of the system of the present invention duringa callback.

FIG. 4 is a block diagram of the system of the present invention duringa normal process.

FIG. 4A is a block diagram of the system of the present invention duringa normal process.

FIG. 5 is a block diagram of a callback process.

FIG. 6 is a Web-page generated by the code.

FIG. 7 is a block diagram of the server of the system of the presentinvention.

FIG. 7A is a block diagram of the user-computer of the system of thepresent invention.

FIG. 8 is a flow chart of a general method of the present invention.

FIG. 9 is a flow chart of a more specific method of the presentinvention.

FIG. 10 is a block diagram of a prior art application stack illustratingthe interactions between the client side and the server-side.

FIG. 11 is a block diagram of an application stack of the presentinvention illustrating the interactions between the client side and theserver-side.

DETAILED DESCRIPTION OF THE INVENTION

As shown in FIG. 3 a system 20 of the invention generally includes aserver-side 25, a client side 30 and a network or preferably theInternet 35. The server-side 25 includes a web-server 40, a handler 45and a JavaScript server 50 preferably having a server-core 55 and aserver-framework 60. The client-side 30 includes a Web-browser 65 has aclient-framework 70, a client-side JavaScript code 75 and a renderingengine 80. The server-framework 60 accesses filesystems 85 and databases90, as well as the Internet 35. A more detailed description of theabilities of the running JavaScript on the server-side and client-sideis disclosed in Colton et al., U.S. patent application Ser. No.12/270,817, filed Nov. 13, 2008 for A Web Server Based On The SameParadigms As Web-Clients, which is hereby incorporated by reference inits entirety. An additional detail of facilitated server-side toclient-side communications is disclosed in Colton et al., U.S. patentapplication Ser. No. 12/276,327, filed Nov. 22, 2008 for a System AndMethod For Facilitated Client-Side To server-Side Communications, whichis hereby incorporated by reference in its entirety.

In FIG. 3, the system 20 is shown during a callback operation. Thecallback begins at the client-side JavaScript code 75 with a callbackrequest sent to the client-framework 70. A HTTP GET/request istransmitted over the Internet 35 to the server-side 25, and received atthe Web-server 40. The HTTP GET/request is sent to the server-core 55which sends the HTTP GET/request as a callback to the server-framework60. The server-framework 60 receives the callback, deserializes,performs the get functions, invokes, serializes and sends the responseto the callback to the server-core 55. The server-core 55 sends theresponse to the Web-server 40 which sends the response over the Internet35 to client-framework 70 on the Web-browser 65.

In FIG. 4, the system 20 is shown during a normal process. The processbegins with a HTTP GET/request for a Web-page sent over the Internet 35from the Web-browser 65 on the client-side 30 to the server-side 25. TheHTTP Request is sent to the handler server 45. The HTML Web-page is thensent to the script server architecture 50. The server-core 55 of thescript server architecture 50 parses the HTML Web-page to create a HTMLDOM of the HTML Web-page. The server-core 55 also parses and interpretsthe JavaScript of the HTML Web-page. The server-framework 60 accessesdatabases 90 and filesystems 85 to respond to the Requests for the HTMLWeb-page. The server-framework 60 also injects proxies to modify theHTML Web-page. The server-core 55 serializes the DOM back to the HTMLWeb-page and the web-server 40 transmits the HTML Web-page to theclient-side 30 where the Web-browser 65 renders the HTML Web-page fordisplay for a user. As shown in FIG. 4A, a Web server (e.g., apacheserver) 41 receives a request from the client-side. The request 67 issent to the handler server (PHP, Ruby or Java language) 45. The handlerserver 45 feeds the HTML document to script server-core 55 which beginsto parse the HTML document thereby building the DOM tree for the HTMLdocument on the server-side. Events and callbacks are sent to the scriptserver-framework 60. The script server adds <script> tags to the DOM andexecutes them if the <script> has a runat attribute that indicates the<script> should be run on the server. During the parsing and execution,external content from filesystems 85, databases 90, and the like arefetched and loaded into the HTML document. After the DOM is loaded, theonserverload event is fired from the script server framework 60. Thescript server architecture post-processes the DOM to perform its builtin logic and prepare the DOM for transmission to the client side. Thispost-process includes removing <script> block meant only for the server,replacing function to be proxied with proxies, saving functions thatshould be available as callbacks, and the like. The DOM is serializedback to HTML, and the HTML is streamed back via the web server 41 to thebrowser. A more detailed explanation of event-driven JavaScriptarchitecture is set forth in Colton et al., U.S. patent application Ser.No. 12/273,539, filed on Nov. 18, 2008, for a Flexible, Event-DrivenJavaScript Server Architecture, which is hereby incorporated byreference in its entirety.

FIGS. 10 and 11 illustrate the difference in the application stacksbetween the prior art and the present invention. In both FIGS. 10 and11, a client-side is designated 30 includes the HTML/DOM, CSS andJavaScript. In both FIGS. 10 and 11, arrow 91 is a request, arrow 92 isa response and arrow (both directions) 93 is a callback. The server-side25 is the difference. The server-side 25 of the prior art is PHP, Java,RoR and C#. The server-side of the present invention is HTML/DOM, CSSand JavaScript. In the prior art, FIG. 10, Callbacks 93 require that theclient-side 30 wrap, send, receive and unwrap the callback while theserver-side 25 is required to receive, unwrap, run, wrap and send thecallback. In the present invention, callbacks 93 are handled viaXMLHttpRequests. When the server-side receives the request, thescript-server architecture preferably creates a new, empty HTMLdocument. The script-server architecture retrieves to this HTML documentthe saved functions needed to be made available during the callback. Ifa function designated oncallback is located, it is executed in order tocreate an environment needed during a callback, especially if the savedfunctions are not sufficient. Then, the callback function is executedand the results of the execution are packaged and returned as theresponse to the XMLHttpRequest.

As shown in FIG. 5, the present invention allows the server 50 toexecute the JavaScript functions that are set to runat=“server” orrunat=“both”. These functions might call databases, file systems,communicate across network sockets, or get session data. And since theserver-side engine has a HTML DOM just like the browser, the HTML pagecan be manipulated through standard DOM APIs and your favorite Ajaxlibraries. The present invention also has session objects that can beused to persist data for users during a session or transaction. Anyfunctions set to runat=“server” are stripped from what gets sent to thebrowser 65. Specifically at 1, the page executes on the server 50 and aresulting HTML page is sent to the browser 65. A more detaileddescription of the runat function is set forth in Colton et al., U.S.patent application Ser. No. 12/270,868, filed on Nov. 14, 2008, for aSystem And Method For Tagging Code To Determine Where The Code Runs,which is hereby incorporated by reference in its entirety.

After server 50 sends the resulting HTML page to the browser 65, at 2the browser 65 interprets the HTML page and executes the JavaScriptwithin the HTML page. If JavaScript functions tagged torunat=“server-proxy” are included, then the present inventionautomatically strips out the bodies of those functions and replaces thebodies with a new functions by the same name that know how to invoke theoriginal function on the server 50 using Ajax calls and return theresult either synchronously or asynchronously. Ajax communications donot need to be written using the present invention. Any functions nottagged with a runat attribute or set to runat=“client” or runat=“both”are processed by the browser 65.

Any functions set to runat=“server-proxy” can now be called from thebrowser 65. The function is called as if it were running on the browser65, and the present invention, automatically via XHR communications withthe server 50, marshals the parameters to the server 50 where thefunction executes (calling databases, getting info from the sessiondata, etc. . . . ) and returns the result to the browser 65. The“server-proxy” functions can be invoked either synchronously orasynchronously. At 3, the browser 65 calls the server 50 asynchronouslyfor new information.

The server computer program of the present invention is pre-configuredfor preferable use as a plug-in to the APACHE 2.x web server. To providestandards-compliant JavaScript and DOM capabilities server-side, theserver computer program is built on the MOZILLA engine, which is thesame engine used in the popular FIREFOX browser. The server computerprogram of the present invention is layered into APACHE as an input andoutput filter for use to modify dynamic pages created by otherlanguages, such as PHP or Ruby.

The server computer program of the present invention is preferably acombination of C/C++“Core” code and a server-side JavaScript“Framework.” The server-core 55 provides the JavaScript parser andruntime, HTML parser and DOM engine, and an event architecture thatcalls the server-framework 60 as the document is being processed on theserver-side 25. The server-framework 60 provides the logic, for exampledeciding which code to run on the server-side 25 and which on theclient-side 30, creating proxies on the client-side 30 for callableserver-side functions, serializing and deserializing data, and otherrelated activities. A more detailed description of generating proxies isset forth in Colton et al., U.S. patent application Ser. No. 12/275,182,filed on Nov. 20, 2008, for a System And Method For Auto-GeneratingJavaScript Proxies And Meta-Proxies, which is hereby incorporated byreference in its entirety. Further discussions on proxy generation areset forth in Colton et al., U.S. patent application Ser. No. 12/275,213,filed on Nov. 20, 2008, for a Single Proxy Generation For Multiple WebPages, which is hereby incorporated by reference in its entirety.

On the server side 25, a developer's JavaScript environment is enhancedby the server-framework 60, which provides access to the database (e.g.,MySQL), file system, network, the HTTP Request and Response data, andthe external server-side platforms such as Java, PHP, and Ruby.

An example of code written by a developer and prior to processing by thepresent invention is set forth below.

<html>  <head>   <title>Tasks</title>   <style>    body { font: 9ptArial; float: left; }    .tasks {background-color: #f0f0ff; padding:8px;}    .new-task {Padding-bottom: 8px;}    .task {Padding: 4px; }  </style>   <script type=”text/javascript” runat=”server”>    Var sql =“CREATE TABLE IF NOT EXISTS tasks ( “+     “id int (11) NOT NULL,” +    “description varchar (255),”+     “created datetime NOT NULL” +    “) ENGINE=InnoDB DEFAULT CHARSET=utf8;    Aptana.DB.execute(sql);   Window.onserverload = function( )    {    var resultSet =Aptana.DB.execute(“SELECT * FROM tasks ORDER BY created”);   for (vari=0; i<resultSet.rows.length; i++)   {    var task = resultSet.rows[i];   addTask(task.description, task.id);   }  }  function saveTask(id,description)  {   var resultSet = Aptana.DB.execute(“SELECT * FROM tasksWHERE id = ?”, [id]);   if (resultSet.rows.length > 0) // task alreadyexists   {    Aptana.DB.execute(“UPDATE tasks SET description = ? WHEREid = ?”     [description, id]);   }   else // insert new task   {   Aptana.DB.execute(“INSERT INTO tasks (id, description, created) ” +    “VALUES (?, ?, NOW( ))”,     [id, description]);   }  } saveTask.proxy = true;  function $(id) { returndocument.getElementById(id); }  $.runat = “both”;  functionaddTask(description, id)  {   var newId = id || Math.ceil(1000000000 *Math.random( ));   var div = document.createElement(“div”);   div.id =“task_ ” + newId;   div.className = “task”;   var checkbox =document.createElement(“input”);   checkbox.setAttribute(“type”,“checkbox”);   checkbox.setAttribute(“title”, “done”);  checkbox.setAttribute(“id”, “checkbox_” + newId);  Aptana.setEvent(checkbox, “onclick”, “completeTask (“ + newId +”)”);  div.appendChild(checkbox);   var input =document.createElement(“input”);   input.setAttribute(“type”, “text”);  input.setAttribute(“size”, “60”);   input.setAttribute(“title”,“description”);   input.setAttribute(“id”, “input_” + newId);  input.setAttribute(“value”, description);   Aptana.setEvent(input,“onchange”, “saveTask(“ + newId + ”, this.value)”);  div.appendChild(input);   $(“tasks”).insertBefore(div,$(“tasks”).firstChild);   if (!Aptana.isOnServer)   {    saveTask(newId,description);   }  }  addTask.runat = “both”;  functioncompleteTask(taskId)  {   var div = $(“task_” + taskId);  div.parentNode.removeChild(div);   deleteSavedTask(taskId);  } completeTask.runat = “client”;  function deleteSavedTask(id)  {  Aptana.DB.execute(“DELETE FROM tasks WHERE id = ?”, [id]);  } deleteSavedTask.proxy = true;  </script> </head> <body>  <h2>Tasks ToDo</h2>  <div><i>Any changes should be automatically saved to yourdatabase! </i><br/><br/></div>  <div class=“new-task”>  New:  <inputtype=“text” id=“txt new” size=“60”>  <input type=“button” value=“add”onclick=“addTask($(‘txt_new’).value)”>  </div>  <div id=“tasks”class=“tasks”>  </div>  </body> </html>

Processing of the code by the present invention results in the codebeing formatted as set forth below:

<html>   <head>     <script src=“/aptanagramework.js?version=0.1.1.759”type=“text/j avascript”></script>  <scripttype=“text/javascript”>Aptana.clientData =Aptana.Serialization.fromJSONString(‘{ }’);</script>  <scripttype=“text/javascript”>Aptana.Callback.id =-1407728339; </script> <title>Tasks</title>  <style>   body {    font: 9pt Arial;    float:left;   }   .tasks {    background-color: #f0f0ff;?    padding: 8px;   }  .new-task {    padding-bottom: 8px;   }   .task {    padding: 4px;   }</style> <script type=“text/javascript”>   function $(id)   {    returndocument.getElementById(id);   }   function addTask(description, id)   {   var newId = id || Math.ceil(1000000000 * Math.random( ));    var div= document.createElement(“div”);    div.id = “task_” + newId;   div.className = “task”;    var checkbox =document.createElement(“input”);    checkbox.setAttribute(“type”,“checkbox”);    checkbox.setAttribute(“title”, “done”);   checkbox.setAttribute(“id”, “checkbox_” + newId);   Aptana.setEvent(checkbox,“onclick”, “completeTask (“ + newId +”)”);   div.appendChild(checkbox);    var input =document.createElement(“input”);    input.setAttribute(“type”, “text”);   input.setAttribute(“size”, “60”);    input.setAttribute(“title”,“description”);    input. setAttribute(“id”, “input_” + newId);   input.setAttribute(“value”, description);    Aptana.setEvent(input,“onchange”, “saveTask(“ + newId + ”, this.value)”);   div.appendChild(input);    $(“tasks”).insertBefore(div,$(“tasks”).firstChild);    if (!Aptana.isOnServer)    {    saveTask(newId, description);    }   }   functioncompleteTask(taskId)   {    var div = $(“task_” + taskId);   div.parentNode.removeChild(div);    deleteSavedTask(taskId);   }  function saveTask( )?   {    returnAptana.Callback.invokeFunction.call(null, “saveTask”, arguments);   }  function saveTaskAsync(callback)   {    returnAptana.Callback.invokeFunctionAsync.call(null, callback, “saveTask”,arguments);   }   function deleteSavedTask( )   {    returnAptana.Callback.invokeFunction.call(null, “deleteSavedTask” arguments);  }   function deleteSavedTaskAsync(callback)   {    returnAptana.Callback.invokeFunctionAsync.call(null, callback,“deleteSavedTask”, arguments);   }  </script>  </head>  <body>  <h2>Tasks To Do</h2>   <div>    <i>Any changes should be automaticallysaved to your database!</i>    <br>    <br>   </div>   <divclass=“new-task”>    New:<input id=“txt new” size=“60”type=“text”><input value=“add” onclick=“addTask($(‘txt new’).value)”type=“button”>   </div> <div id=“tasks” class=“tasks”> </div> </body></html>

FIG. 6 is a screen display 99 of the code set forth above.

As shown in FIG. 7, a server-computer 2000 contains server architecture50. The server-architecture 50 includes the server-core 55 and theserver-framework 60. The server-core 55 includes a JavaScript parser 95.The server-computer 2000 is preferably a conventional server-computeravailable from IBM, HP, APPLE, DELL, and SUN.

As shown in FIG. 7A, a user-computer 2002 contains a Web-browser 65. TheWeb-browser 65 preferably includes the client framework 70, client-sideJavaScript code 75 and the rendering engine 80. The user-computer 2002is preferably a conventional user-computer such as a PC available fromHP, DELL, and GATEWAY, or a MAC available from APPLE. The Web-browser 65is preferably MICROSOFT INTERNET EXPLORER, NETSCAPE, APPLE SAFARI,MOZILLA FIREFOX, or OPERA.

A general method 100 of the present invention is shown in FIG. 8. Atblock 102, a HTML document is provided on a web server. At block 104,the HTML DOM is analyzed on the web-server to identify a plurality ofelements of the HTML DOM. At block 106, the plurality of elements of theDocument Object Model of the web-page is manipulated to create aweb-page with a manipulated Document Object Model. At block 108, theweb-page with the manipulated Document Object Model is transmitted tothe client-side.

A more specific method 200 of the present invention is shown in FIG. 9.At block 202, a HTML document is provided on a web server. At block 204,the HTML document is parsed on the web-server to create an HTML DOM. Atblock 206, the HTML DOM is analyzed on the web-server to identify aplurality of elements of the HTML DOM. At block 208, the plurality ofelements of the Document Object Model of the web-page is manipulated tocreate a web-page with a manipulated Document Object Model. At block210, the HTML DOM is serialized back to HTML. At block 212, the HTMLpage is transmitted to the client-side over the Internet. At block 214,the HTML page is interpreted on the web-browser for display on the usercomputer.

From the foregoing it is believed that those skilled in the pertinentart will recognize the meritorious advancement of this invention andwill readily understand that while the present invention has beendescribed in association with a preferred embodiment thereof, and otherembodiments illustrated in the accompanying drawings, numerous changesmodification and substitutions of equivalents may be made thereinwithout departing from the spirit and scope of this invention which isintended to be unlimited by the foregoing except as may appear in thefollowing appended claim. Therefore, the embodiments of the invention inwhich an exclusive property or privilege is claimed are defined in thefollowing appended claims.

We claim as our invention:
 1. A method for on-the-fly post-processing ofa Document Object Model of a webpage server-side, the method comprising:receiving a request for the webpage from a client-side; retrieving anHTML document for the webpage at a server-side; receiving the HTMLdocument for the webpage at a script server on the server-sideon-the-fly prior to transmission to the client-side; parsing the HTMLdocument for the webpage at the script server on the server-side;building a Document Object Model of the webpage at the script server onthe server-side; identifying a plurality of elements of the DocumentObject Model of the webpage; manipulating the plurality of elements ofthe Document Object Model of the webpage to create a manipulatedDocument Object Model of the webpage at the script server on theserver-side; serializing the manipulated Document Object Model of thewebpage at the script server on the server-side into an HTML documentfor a webpage with a manipulated Document Object Model; and transmittingthe HTML document for the webpage with the manipulated Document ObjectModel to the client-side.
 2. The method according to claim 1 whereinmanipulating the plurality of elements of the Document Object Model ofthe webpage comprises replacing the plurality of elements with a newerversion of each element.
 3. The method according to claim 1 whereinmanipulating the plurality of elements of the Document Object Model ofthe webpage comprises removing at least one of the plurality of elementsof the Document Object Model of the webpage.
 4. The method according toclaim 1 wherein manipulating the plurality of elements of the DocumentObject Model of the webpage comprises repositioning at least one of theplurality of elements of the Document Object Model of the webpage. 5.The method according to claim 1 wherein manipulating the plurality ofelements of the Document Object Model of the webpage comprisesrepurposing at least one of the plurality of elements of the DocumentObject Model of the webpage.
 6. The method according to claim 1 whereinmanipulating the plurality of elements of the Document Object Model ofthe webpage comprises rebranding at least one of the plurality ofelements of the Document Object Model of the webpage.
 7. The methodaccording to claim 1 wherein manipulating the plurality of elements ofthe Document Object Model of the webpage comprises adjusting forimproved accessibility at least one of the plurality of elements of theDocument Object Model of the webpage.
 8. The method according to claim 1wherein manipulating the plurality of elements of the Document ObjectModel of the webpage comprises compressing at least one of the pluralityof elements of the Document Object Model of the webpage.
 9. The methodaccording to claim 1 wherein manipulating the plurality of elements ofthe Document Object Model of the webpage comprises caching at least oneof the plurality of elements of the Document Object Model of the webpageon the server-side.
 10. The method of claim 1 wherein the web servercomprises the script server.
 11. The method of claim 1 wherein the webserver is operatively connected to the script server on the server-side.12. The method of claim 1 further comprising the step of transmittingthe HTML document for the webpage with the manipulated Document ObjectModel to a web server.